Description
buildVisual() rescanned+rewrapped+restyled the whole document on every View, cursor move, and scroll tick (no caching). Per single scroll row: 20ms/62MB at 500 lines, 133ms/345MB at 2000 lines w/ spell. Caused open-doc lag and scroll stutter. Fix: memoize the scan+wrap model (e.visual []vrow), invalidate only on scan/wrap input changes (Lines/Width/theme/spell/codeFile). Scroll/render now O(visible) ~0.4ms, independent of doc size.
Acceptance Criteria
- #1 Scroll + render reuse cached visual model (buildCount<=1 across scroll loop)
- #2 Edits/theme/spell/width changes invalidate cache (no stale render)
- #3 All tests pass